﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RR71Request", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR71Request))]
    public class RR71RequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRR71Request clazz;
        
        public RR71RequestSerializer(IRR71Request clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("cFailiNimi");
            if (clazz.CFailiNimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.CFailiNimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : CFailiNimi");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="cFailiNimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR71Request>cFailiNimi");
                }
                clazz.CFailiNimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("cFailiNimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR71Request>cFailiNimi", Reader.LocalName);
            }
        }
    }
}
